<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>敲代码的小盆友</title>
    <style>
        /* 起手式, 100%保证我们的样式设置可以不受默认影响 */
        * {
            /* 消除网页的默认外边距 */
            margin: 0px;
            /* 消除网页的默认内边距 */
            padding: 0px;
            box-sizing: border-box;
        }

        html,
        body {
            width: 100%;
            height: 100%;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background-color: #f4f4f9;
        }

        .container .navbar {
            width: 100%;
            height: 60px;
            background-color: #2c3e50;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            display: flex;
            align-items: center;
            padding: 0 20px;
        }

        .container .navbar a {
            width: auto;
            color: white;
            font-size: 16px;
            line-height: 60px;
            text-decoration: none;
            padding: 0 15px;
            transition: background-color 0.3s ease;
        }

        /* 设置鼠标事件 */
        .container .navbar a:hover {
            background-color: #3498db;
        }

        .container .navbar .login {
            margin-left: auto;
        }

        .container .content {
            width: 80%;
            max-width: 800px;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            margin: 200px auto 0;
            text-align: center;
            padding: 40px;
        }

        .container .content .font_ {
            display: block;
            margin-top: 20px;
            text-decoration: none;
            font-size: 18px;
            color: #2c3e50;
        }

        .container .content .font_:hover {
            color: #3498db;
        }

        .container h1.font_ {
            font-size: 36px;
            font-weight: 600;
        }

        .container div a {
            display: block;
            text-align: center;
            margin-top: 20px;
            color: #999;
            font-size: 14px;
        }
    </style>
</head>

<body>
    <div class="container">
        <!-- 导航栏， 功能不实现-->
        <div class="navbar">
            <a href="#">首页</a>
            <a href="/all_questions">题库</a>
            <a class="login" id="logoutLink" href="/logout" style="display: none;">退出</a> 
            <a class="login" id="loginLink" href="/login">登录</a>
            <a href="/user/submissions">我的提交</a>
            <script>
                function checkLogin() {
                    // 1. 精准获取元素
                    const loginLink = document.getElementById('loginLink');
                    const logoutLink = document.getElementById('logoutLink');
                    
                    // 2. 检查Cookie中是否有user_id
                    const isLoggedIn = document.cookie.split(';').some(cookie => 
                        cookie.trim().startsWith('user_id=')
                    );
            
                    // 3. 根据登录状态切换显示
                    if (isLoggedIn) {
                        loginLink.style.display = 'none';
                        logoutLink.style.display = 'inline-block';
                    } else {
                        loginLink.style.display = 'inline-block';
                        logoutLink.style.display = 'none';
                    }
                }
            
                // 4. 确保DOM加载完成后执行
                document.addEventListener('DOMContentLoaded', checkLogin);
            </script>
        </div>
        <!-- 网页的内容 -->
        <div class="content">
            <h1 class="font_">敲代码的小盆友</h1>
            <a class="font_" href="/all_questions">点击我开始编程啦!</a>
        </div>
        <div>
            <a href="https://beian.miit.gov.cn/">皖ICP备2023008838号</a>
        </div>
    </div>
</body>

</html>